package org.zuel.boot.demo.controller;

import org.zuel.boot.demo.entity.SysUser;
import org.zuel.boot.demo.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.zuel.boot.demo.web.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 *  控制器
 *
 * @author ikun
 */
@Api(tags = "管理")
@RestController
@RequestMapping("/zuel")
public class SysUserController{

    private ISysUserService sysUserService;

    @Autowired
    public SysUserController(ISysUserService sysUserService){
        this.sysUserService = sysUserService;
    }

    @ApiOperation("查询列表")
    @GetMapping("/sysUser/list")
    public PageResult<SysUser> list(HttpServletRequest request) {
        PageParam<SysUser> pageParam = new PageParam<>(request);
        return sysUserService.list(pageParam);
    }

    @ApiOperation("登录")
    @PostMapping("/login")
    public JsonResult login(@RequestBody SysUser model) {
        return sysUserService.login(model);
    }

    @ApiOperation("添加")
    @PostMapping("/sysUser/add")
    public JsonResult add(@RequestBody SysUser model) {
    return sysUserService.add(model);
    }

    @ApiOperation("修改")
    @PostMapping("/sysUser/update")
    public JsonResult update(@RequestBody SysUser model) {
    return sysUserService.update(model);
    }

    @ApiOperation("删除")
    @GetMapping("/sysUser/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return sysUserService.delete(ids);
    }

}